package bTree.LeetCode;

import java.util.ArrayList;
import java.util.List;

public class 子集 {
    List<List<Integer>> res = new ArrayList<>();

    public List<List<Integer>> subsets(int[] nums) {
        res.add(new ArrayList<>());
        List<Integer>path=new ArrayList<>();
        backTraching(nums,path,0);
        return res;
    }

    private void backTraching(int[] nums, List<Integer> path, int start) {
        for (int i = start; i < nums.length; i++) {
            int num = nums[i];
            path.add(num);
            res.add(new ArrayList<>(path));
            backTraching(nums,path,i+1);
            path.remove(path.size()-1);
        }
    }
}